package com.gzz.orchid.context.infrastructure.definition;

import com.gzz.orchid.common.core.support.IBaseEnum;

/**
 * @author higmd
 */
public enum Relaction implements IBaseEnum {
    SIMPLE(1, "简单关系"),
    MULTIPLE(2, "多对多关系");

    private final int code;
    private final String text;

    Relaction(int code, String text) {
        this.code = code;
        this.text = text;
    }

    public static Relaction parse(int val) {
        for (Relaction item : Relaction.values()) {
            if (item.code == val) {
                return item;
            }
        }
        throw new IllegalArgumentException("Invalid Relaction value: " + val);
    }

    public static Relaction of(String name) {
        return Enum.valueOf(Relaction.class, name);
    }

    @Override
    public Integer getValue() {
        return code;
    }

    @Override
    public String getLabel() {
        return text;
    }
}
